.class Lnet/oauth/client/httpclient4/OAuthScheme;
.super Lorg/apache/http/impl/auth/RFC2617Scheme;
.source "OAuthScheme.java"


# instance fields
.field private complete:Z

.field private final defaultRealm:Ljava/lang/String;


# direct methods
.method constructor <init>(Ljava/lang/String;)V
    .locals 0
    .parameter "defaultRealm"

    .prologue
    .line 43
    invoke-direct {p0}, Lorg/apache/http/impl/auth/RFC2617Scheme;-><init>()V

    .line 44
    iput-object p1, p0, Lnet/oauth/client/httpclient4/OAuthScheme;->defaultRealm:Ljava/lang/String;

    .line 45
    return-void
.end method

.method private getAccessor(Lorg/apache/http/auth/Credentials;)Lnet/oauth/OAuthAccessor;
    .locals 5
    .parameter "credentials"

    .prologue
    const/4 v4, 0x0

    .line 116
    instance-of v0, p1, Lnet/oauth/client/httpclient4/OAuthCredentials;

    if-eqz v0, :cond_0

    .line 117
    check-cast p1, Lnet/oauth/client/httpclient4/OAuthCredentials;

    .end local p1
    invoke-virtual {p1}, Lnet/oauth/client/httpclient4/OAuthCredentials;->getAccessor()Lnet/oauth/OAuthAccessor;

    move-result-object v0

    .line 119
    :goto_0
    return-object v0

    .restart local p1
    :cond_0
    new-instance v0, Lnet/oauth/OAuthAccessor;

    new-instance v1, Lnet/oauth/OAuthConsumer;

    invoke-interface {p1}, Lorg/apache/http/auth/Credentials;->getUserPrincipal()Ljava/security/Principal;

    move-result-object v2

    invoke-interface {v2}, Ljava/security/Principal;->getName()Ljava/lang/String;

    move-result-object v2

    invoke-interface {p1}, Lorg/apache/http/auth/Credentials;->getPassword()Ljava/lang/String;

    move-result-object v3

    invoke-direct {v1, v4, v2, v3, v4}, Lnet/oauth/OAuthConsumer;-><init>(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lnet/oauth/OAuthServiceProvider;)V

    invoke-direct {v0, v1}, Lnet/oauth/OAuthAccessor;-><init>(Lnet/oauth/OAuthConsumer;)V

    goto :goto_0
.end method

.method private getHttpUriRequest(Lorg/apache/http/HttpRequest;)Lorg/apache/http/client/methods/HttpUriRequest;
    .locals 2
    .parameter "request"

    .prologue
    .line 102
    :goto_0
    instance-of v1, p1, Lorg/apache/http/impl/client/RequestWrapper;

    if-eqz v1, :cond_0

    move-object v1, p1

    .line 103
    check-cast v1, Lorg/apache/http/impl/client/RequestWrapper;

    invoke-virtual {v1}, Lorg/apache/http/impl/client/RequestWrapper;->getOriginal()Lorg/apache/http/HttpRequest;

    move-result-object v0

    .line 104
    .local v0, original:Lorg/apache/http/HttpRequest;
    if-ne v0, p1, :cond_1

    .line 109
    .end local v0           #original:Lorg/apache/http/HttpRequest;
    :cond_0
    instance-of v1, p1, Lorg/apache/http/client/methods/HttpUriRequest;

    if-eqz v1, :cond_2

    .line 110
    check-cast p1, Lorg/apache/http/client/methods/HttpUriRequest;

    .line 112
    .end local p1
    :goto_1
    return-object p1

    .line 107
    .restart local v0       #original:Lorg/apache/http/HttpRequest;
    .restart local p1
    :cond_1
    move-object p1, v0

    .line 108
    goto :goto_0

    .line 112
    .end local v0           #original:Lorg/apache/http/HttpRequest;
    :cond_2
    const/4 p1, 0x0

    goto :goto_1
.end method


# virtual methods
.method public authenticate(Lorg/apache/http/auth/Credentials;Lorg/apache/http/HttpRequest;)Lorg/apache/http/Header;
    .locals 11
    .parameter "credentials"
    .parameter "request"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lorg/apache/http/auth/AuthenticationException;
        }
    .end annotation

    .prologue
    const/4 v10, 0x0

    .line 80
    invoke-direct {p0, p2}, Lnet/oauth/client/httpclient4/OAuthScheme;->getHttpUriRequest(Lorg/apache/http/HttpRequest;)Lorg/apache/http/client/methods/HttpUriRequest;

    move-result-object v7

    .line 81
    .local v7, uriRequest:Lorg/apache/http/client/methods/HttpUriRequest;
    if-eqz v7, :cond_0

    .line 82
    invoke-interface {v7}, Lorg/apache/http/client/methods/HttpUriRequest;->getURI()Ljava/net/URI;

    move-result-object v8

    invoke-virtual {v8}, Ljava/net/URI;->toString()Ljava/lang/String;

    move-result-object v6

    .line 83
    .local v6, uri:Ljava/lang/String;
    invoke-interface {v7}, Lorg/apache/http/client/methods/HttpUriRequest;->getMethod()Ljava/lang/String;

    move-result-object v4

    .line 91
    .local v4, method:Ljava/lang/String;
    :goto_0
    :try_start_0
    new-instance v3, Lnet/oauth/OAuthMessage;

    const/4 v8, 0x0

    invoke-direct {v3, v4, v6, v8}, Lnet/oauth/OAuthMessage;-><init>(Ljava/lang/String;Ljava/lang/String;Ljava/util/Collection;)V

    .line 92
    .local v3, message:Lnet/oauth/OAuthMessage;
    invoke-direct {p0, p1}, Lnet/oauth/client/httpclient4/OAuthScheme;->getAccessor(Lorg/apache/http/auth/Credentials;)Lnet/oauth/OAuthAccessor;

    move-result-object v0

    .line 93
    .local v0, accessor:Lnet/oauth/OAuthAccessor;
    invoke-virtual {v3, v0}, Lnet/oauth/OAuthMessage;->addRequiredParameters(Lnet/oauth/OAuthAccessor;)V

    .line 94
    invoke-virtual {p0}, Lnet/oauth/client/httpclient4/OAuthScheme;->getRealm()Ljava/lang/String;

    move-result-object v8

    invoke-virtual {v3, v8}, Lnet/oauth/OAuthMessage;->getAuthorizationHeader(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v1

    .line 95
    .local v1, authorization:Ljava/lang/String;
    new-instance v8, Lorg/apache/http/message/BasicHeader;

    const-string v9, "Authorization"

    invoke-direct {v8, v9, v1}, Lorg/apache/http/message/BasicHeader;-><init>(Ljava/lang/String;Ljava/lang/String;)V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    return-object v8

    .line 86
    .end local v0           #accessor:Lnet/oauth/OAuthAccessor;
    .end local v1           #authorization:Ljava/lang/String;
    .end local v3           #message:Lnet/oauth/OAuthMessage;
    .end local v4           #method:Ljava/lang/String;
    .end local v6           #uri:Ljava/lang/String;
    :cond_0
    invoke-interface {p2}, Lorg/apache/http/HttpRequest;->getRequestLine()Lorg/apache/http/RequestLine;

    move-result-object v5

    .line 87
    .local v5, requestLine:Lorg/apache/http/RequestLine;
    invoke-interface {v5}, Lorg/apache/http/RequestLine;->getUri()Ljava/lang/String;

    move-result-object v6

    .line 88
    .restart local v6       #uri:Ljava/lang/String;
    invoke-interface {v5}, Lorg/apache/http/RequestLine;->getMethod()Ljava/lang/String;

    move-result-object v4

    .restart local v4       #method:Ljava/lang/String;
    goto :goto_0

    .line 96
    .end local v5           #requestLine:Lorg/apache/http/RequestLine;
    :catch_0
    move-exception v2

    .line 97
    .local v2, e:Ljava/lang/Exception;
    new-instance v8, Lorg/apache/http/auth/AuthenticationException;

    invoke-direct {v8, v10, v2}, Lorg/apache/http/auth/AuthenticationException;-><init>(Ljava/lang/String;Ljava/lang/Throwable;)V

    throw v8
.end method

.method public getRealm()Ljava/lang/String;
    .locals 1

    .prologue
    .line 49
    invoke-super {p0}, Lorg/apache/http/impl/auth/RFC2617Scheme;->getRealm()Ljava/lang/String;

    move-result-object v0

    .line 50
    .local v0, realm:Ljava/lang/String;
    if-nez v0, :cond_0

    .line 51
    iget-object v0, p0, Lnet/oauth/client/httpclient4/OAuthScheme;->defaultRealm:Ljava/lang/String;

    .line 53
    :cond_0
    return-object v0
.end method

.method public getSchemeName()Ljava/lang/String;
    .locals 1

    .prologue
    .line 57
    const-string v0, "OAuth"

    return-object v0
.end method

.method public isComplete()Z
    .locals 1

    .prologue
    .line 61
    iget-boolean v0, p0, Lnet/oauth/client/httpclient4/OAuthScheme;->complete:Z

    return v0
.end method

.method public isConnectionBased()Z
    .locals 1

    .prologue
    .line 65
    const/4 v0, 0x0

    return v0
.end method

.method public processChallenge(Lorg/apache/http/Header;)V
    .locals 1
    .parameter "challenge"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lorg/apache/http/auth/MalformedChallengeException;
        }
    .end annotation

    .prologue
    .line 73
    invoke-super {p0, p1}, Lorg/apache/http/impl/auth/RFC2617Scheme;->processChallenge(Lorg/apache/http/Header;)V

    .line 74
    const/4 v0, 0x1

    iput-boolean v0, p0, Lnet/oauth/client/httpclient4/OAuthScheme;->complete:Z

    .line 75
    return-void
.end method
